<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head>
    <base th:href="${#request.getContextPath()}+'/'">
    <title>代办事项</title>
    <meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" src="layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

  </head>
  
  <body class="layui-anim">
    <div class="x-body">
    <div class="layui-row">
    <div class="layui-fluid">
      <div class="layui-card-body" >
        <form class="layui-form" lay-filter="component-form-group">
          <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
              <input type="hidden" name="id" class="layui-input" >
              <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题.." class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
              <textarea name="content" lay-verify="required" placeholder="请输入内容..." class="layui-textarea"></textarea>
            </div>
          </div>
          
          <div class="layui-form-item layui-layout-admin">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="submission" lay-submit="">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
      </div>
    </div>
  </div>
  </div>
  <script type="text/javascript" src="js/common/common.js"></script>
  <script type="text/javascript">
	   $(function(){
        var title="待办事项";
        var size=['550px', '450px'];
        var update_url='todo/update.jhtml';
        var delete_url="todo/delete.jhtml";
        var cols=[ 
            {checkbox: true, fixed: true},
            {field: 'createDate',width:"130", title: '创建时间'},
            {field: 'title' ,title: '标题',width:"130"},
            {field: 'content' ,title: '内容',width:"130"},
            {title:'操作', toolbar: '#barDemo',fixed: 'right',align: 'center',width:"180",fixed: 'right'}
        ];
        //
        function loadData(data){
            var ret={
                "id": data.id,
                "capacity": data.capacity,
                "cryogen": data.cryogen,
                "heating": data.heating,
                "xinfnorm": data.xinfnorm,
                "dehumidification": data.dehumidification,
                "iteminofId": data.iteminofId,
                "mmanufacturerId": data.mmanufacturerId
            };
            return ret;
        }
        //监听提交
            layui.use('form', function(){
                var form = layui.form;
                //自定义验证规则
                form.verify({
                    required: [/[\S]+/, "必填项不能为空"],

                });
                //验证通过后提交数据到后台
                form.on('submit(submission)', function(data){
                    /* layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                  })  */
                    postUpdate(data);
                    return false;
                });
            });
            
             window.postUpdate = function (data){
                $.ajax({
                    url: update_url,
                    type: "POST",
                    data:{"data": JSON.stringify(data.field)},
                    dataType: "json",
                    success: function(data){
                        if(data.code==0){
                            layer.closeAll();
                            layer.msg(data.msg, {time:600, icon: 1},function(){
                              parent.location.reload();
                            });

                        }else{
                            layer.msg(data.msg, {icon: 5});
                        }
                    },
                    error:function(jqXHR, textStatus, errorThrown){
                        layer.open({
                            title: "閿欒淇℃伅",
                            type: 1,
                            content: jqXHR.responseText, //statusText
                            btn: ['鍏抽棴'] //鍙互鏃犻檺涓寜閽�
                        });
                    }
                });
            }
    });
 
  </script>
  </body>
</html>
